using AutoMapper;
using Three.BookStore.ProductionSystem.ShiftManagement;
using Three.BookStore.ProductionSystem.ShiftManagement.Dtos;
using ThridGroup.ERP.Application.Contracts.DTO;
using ThridGroup.ERP.DTO;
using ThridGroup.ERP.DTO.ProductionSystem;
using ThridGroup.ERP.DTO.ProductionSystem.RepairOrderDto;
using ThridGroup.ERP.DTO.ProductionSystem.ShiftSchedulingManagement.Procurement;
using ThridGroup.ERP.DTO.ShiftSchedulingManagementDto;
using ThridGroup.ERP.DTO.SupplierDto;
using ThridGroup.ERP.ProductionSystem;
using ThridGroup.ERP.RBAC;
using ThridGroup.ERP.WarehouseManagement;
using ThridGroup.ERP.DTO.ProductionSystem.RepairOrderDto;
using ThridGroup.ERP.DTO.WarehouseManagement;

namespace ThridGroup.ERP;

public class ERPApplicationAutoMapperProfile : Profile
{
    public ERPApplicationAutoMapperProfile()
    {
        /* You can configure your AutoMapper mapping configuration here.
         * Alternatively, you can split your mapping configurations
         * into multiple profile classes for a better organization. */
         
        // 角色权限映射
        CreateMap<CreateRolePermissionDto, RolePermission>();
        CreateMap<RolePermission, RolePermissionListDto>();
        
        // 角色映射
        CreateMap<CreateRoleDto, Role>();
        CreateMap<Role, RoleListDto>();

        // 节假日设置映射
        CreateMap<HolidaySettingModel, HolidaySettingDto>().ReverseMap();
        CreateMap<CreateOrUpdateHolidaySettingDto, HolidaySettingModel>();
        // 权限映射
        CreateMap<Permission, PermissionlistDto>();
        
        // 用户映射
        CreateMap<UserDTO, User>();
        CreateMap<User, UserDTO>();

        // 供应商映射配置
        CreateMap<SupplierModel, SupplierDto>();
        CreateMap<CreateSupplierDto, SupplierModel>()
            .ForMember(dest => dest.Id, opt => opt.Ignore())
            .ForMember(dest => dest.IsDeleted, opt => opt.MapFrom(src => false));
        CreateMap<UpdateSupplierDto, SupplierModel>()
            .ForMember(dest => dest.IsDeleted, opt => opt.Ignore());

        // 物料分类映射
        CreateMap<MaterialTypeDto, MaterialType>();
        CreateMap<MaterialType, MaterialTypeDto>();

        // 工序映射
        CreateMap<CreateProcedureDto, ProcedureModel>();
        CreateMap<ProcedureModel, ProcedurelistDto>();

        // 设备分类映射
        CreateMap<EquipmentTypeModel, EquipmentTypeTreeDto>();
        CreateMap<EquipmentTypeModel, EquipmentTypeListDto>();

        // 设备台账映射
        CreateMap<CreateDeviceLedgerDto, DeviceLedgerModel>();
        CreateMap<DeviceLedgerModel, DeviceLedgerDtoList>();
   
        
        // 车间映射
        CreateMap<WorkshopDto, Workshop>();
        CreateMap<Workshop, WorkshopDto>();
        
        // 班组映射
        CreateMap<TeanListDto, TeamModel>();
        CreateMap<TeamModel, TeanListDto>();
        
        // 采购入库映射
        CreateMap<ProcurementDto, ProcurementModelS>();
        CreateMap<ProcurementModelS, ProcurementDto>();

        // 点检保养计划映射 - 使用完全限定名称避免冲突
        CreateMap<ThridGroup.ERP.Application.Contracts.DTO.MaintenanceplanDto, MaintenanceplanModel>();
        CreateMap<MaintenanceplanModel, ThridGroup.ERP.Application.Contracts.DTO.MaintenanceplanDto>();

        CreateMap<OutgoingInspectionDto, OutgoingInspection>().ReverseMap();
        // CreateMap<Student, StudentDto>().ReverseMap();

        // 来料检验映射
        CreateMap<ThridGroup.ERP.ProductionSystem.IncomingInspection, ThridGroup.ERP.DTO.ProductionSystemDto.IncomingInspectionDto.IncomingInspectionListDto>();
        
        // 库存现有量映射
        CreateMap<InventoryModel, InventoryDto>().ReverseMap();
        
        // 外协入库映射
        CreateMap<CreateOutsourcingWarehousingDto, ThridGroup.ERP.WarehouseManagement.OutsourcingWarehousing>();
        CreateMap<ThridGroup.ERP.WarehouseManagement.OutsourcingWarehousing, OutsourcingWarehousingListDto>();
    }
}
